package com.dylearn.serve.impl;

import com.dylearn.domain.Book;
import com.dylearn.mapper.BookMapper;
import com.dylearn.serve.BookService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

public class BookService2 implements BookService {
//一般写法
    @Autowired
    BookMapper bookMapper;

    @Override
    public Boolean save(Book book) {

        return bookMapper.insert(book) > 0;
    }

    @Override
    public Boolean delectById(Book book) {

        return bookMapper.deleteById(book.getId()) > 0;
    }

    @Override
    public Book getById(Book book) {
        return bookMapper.selectById(book.getId());
    }

    @Override
    public Boolean update(Book book) {
        return bookMapper.updateById(book) > 0;
    }

    @Override
    public void getPage(Book book) {

    }

    @Override
    public List<Book> getAll() {
        return bookMapper.selectList(null);
    }
}
